package com.koron.ticket.work.logicticket.ychoistingsafety;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.koron.bean.base.Response;
import com.koron.bean.workflow.RedirectQuery;
import com.koron.common.core.util.CodeTools;
import com.koron.common.core.util.FastJsonUtils;
import com.koron.ticket.utils.StringUtils;
import com.koron.ticket.work.common.bean.TicketBaseMsg;
import com.koron.ticket.work.common.service.FifteenTablesService;
import com.koron.ticket.work.common.service.YcCommonService;
import com.koron.ticket.work.enums.TicketNodeStatus;
import com.koron.ticket.work.enums.TicketStatus;
import com.koron.ticket.work.enums.WorkFlowType;
import com.koron.ticket.work.logicticket.hightask.bean.HighTaskDto;
import com.koron.ticket.work.logicticket.ychoistingsafety.bean.HoistingDto;
import com.koron.ticket.work.logicticket.ychoistingsafety.bean.HoistingPrint;
import com.koron.ticket.work.logicticket.ychotsafework.bean.HeatAnalysisBean;
import com.koron.ticket.work.logicticket.ychotsafework.mapper.HeatAnalysisBeanMapper;
import com.koron.ticket.work.securityarrangement.bean.SecurityArrangement;
import com.koron.ticket.work.workPermit.bean.WorkPermit;
import com.koron.ticket.work.workPermit.service.WorkPermitService;
import com.koron.ticket.work.workend.bean.WorkEnd;
import com.koron.ticket.work.workflow.bean.WorkFlow;
import com.koron.ticket.work.workflow.mapper.WorkFlowMapper;
import com.koron.ticket.work.workflow.service.WorkFlowService;
import com.koron.ticket.work.worklocation.bean.WorkLocationBean;
import com.koron.ticket.work.workmember.bean.WorkMember;
import com.koron.ticket.work.workteam.bean.WorkTeam;
import com.koron.ticket.work.workticket.bean.WorkTicket;
import com.koron.ticket.work.workticket.service.WorkTicketService;
import com.koron.ticket.work.workycinfo.bean.TicketYcInfoBean;
import com.koron.ticket.work.workycinfo.service.WorkYcInfoService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;

@Service
public class HoistingService {

    @Autowired
    private FifteenTablesService fifteenTablesService;

    @Autowired
    private WorkFlowService workFlowService;

    @Autowired
    private WorkTicketService workTicketService;

    @Autowired
    private WorkPermitService workPermitService;

    @Autowired
    private WorkYcInfoService workycinfoservice;

    @Autowired
    private YcCommonService yccommonservice;

    @TaskAnnotation("writeSave")
    public Response writeSave(SessionFactory factory, HoistingDto dto) {
        workTicketService.checkTimeOut(factory, dto.getId(), dto.getUpdateTime());//检查信息是否过期
        String id = CodeTools.getCode32();

        // 工作票主表
        WorkTicket workticket = Convert.convert(WorkTicket.class, dto);
        // 动火安全作业票
        TicketYcInfoBean ticketycinfobean = Convert.convert(TicketYcInfoBean.class, dto);
        // 工作票基础信息
        TicketBaseMsg ticketbasemsg = Convert.convert(TicketBaseMsg.class, dto);

        ticketycinfobean.setTicketType(workticket.getType());
        if (StrUtil.isNotBlank(workticket.getId())) {
            workTicketService.update(factory, workticket);
            ticketycinfobean.setWorkTicketId(workticket.getId());
        } else {
            workticket.setId(id);
            ticketycinfobean.setWorkTicketId(id);
            workTicketService.insert(factory, workticket);
        }
        workycinfoservice.save(factory, ticketycinfobean);

        // 动火分析
//        HeatAnalysisBeanMapper heatanalysisbeanmapper = factory.getMapper(HeatAnalysisBeanMapper.class);
//        heatanalysisbeanmapper.deleteByWorkTicketId(dto.getId());
//        if(CollUtil.isNotEmpty(dto.getHeatanAlysislist())) {
//            dto.getHeatanAlysislist().stream().forEach(g->{
//                g.setId(CodeTools.getCode32());
//                g.setWorkTicketId(workticket.getId());
//            });
//            heatanalysisbeanmapper.batchInsert(dto.getHeatanAlysislist());
//        }

        // 更新工作票基础信息
        yccommonservice.updateTicketMsg(factory, workticket.getId(), ticketbasemsg);

        return Response.success(workticket.getId());
    }


    @TaskAnnotation("writeSubmit")
    public Response writeSubmit(SessionFactory factory, HighTaskDto dto) {
        WorkTicket workticket = Convert.convert(WorkTicket.class, dto);
        String workTicketId = yccommonservice.ycWriteSubmitByWorkFlowType(factory, workticket, WorkFlowType.HighTaskTicketWork.getWorkFlow());
        return Response.success(workTicketId);
    }

    @TaskAnnotation("signSave")
    public Response signSave(SessionFactory factory, List<WorkFlow> workFlows) {
        WorkFlowMapper workFlowMapper = factory.getMapper(WorkFlowMapper.class);
        if (CollUtil.isNotEmpty(workFlows)) {
            workTicketService.checkTimeOut(factory, workFlows.get(0).getWorkTicketId(), workFlows.get(0).getUpdateTime());//检查信息是否过期
            workFlowMapper.deleteByWorkTicketIdAndStatus(workFlows.get(0).getWorkTicketId(), TicketStatus.SIGN.getStatus());
        }
        workFlowService.batchInsert(factory, workFlows);
//        yccommonservice.signSave(factory, workFlow);
        return Response.success("提交/保存成功");
    }

//    @TaskAnnotation("countersignSave")
//    public Response countersignSave(SessionFactory factory, WorkFlow workFlow) {
//        yccommonservice.countersignSave(factory, workFlow);
//        return Response.success("提交/保存成功");
//    }

    @TaskAnnotation("acceptSave")
    public Response acceptSave(SessionFactory factory, List<WorkFlow> workFlows) {
        WorkFlowMapper workFlowMapper = factory.getMapper(WorkFlowMapper.class);
        if (CollUtil.isNotEmpty(workFlows)) {
            workTicketService.checkTimeOut(factory, workFlows.get(0).getWorkTicketId(), workFlows.get(0).getUpdateTime());//检查信息是否过期
            workFlowMapper.deleteByWorkTicketIdAndStatus(workFlows.get(0).getWorkTicketId(), TicketStatus.ACCEPT.getStatus());
        }
        workFlowService.batchInsert(factory, workFlows);
//        yccommonservice.acceptSave(factory, workFlow);
        return Response.success("提交/保存成功");
    }

    @TaskAnnotation("permitSave")
    public Response permitSave(SessionFactory factory, WorkPermit workPermit) {
        yccommonservice.permitSave(factory, workPermit);
        return Response.success("待许可-提交/保存成功");
    }

//    @TaskAnnotation("ticketEndSave")
//    public Response ticketEndSubmitOrSave(SessionFactory factory, WorkEnd workEnd) {
//        List<WorkFlow> workFlowList = workEnd.getWorkFlowList();
//        workFlowService.batchInsert(factory, workFlowList);
//        return Response.success("工作票待终结-提交/保存成功");
//    }

    @TaskAnnotation("workflowUpdate")
    public Response workflowUpdate(SessionFactory factory, RedirectQuery redirectQuery) throws ParseException {
        Integer operation = redirectQuery.getOperation();
        String workTicketId = redirectQuery.getDataId();
        WorkTicket workTicket = workTicketService.queryById(factory, workTicketId);
        // 提交前状态
        Integer status = workTicket.getStatus();
        String type = workTicket.getType();

        // 1. 如果被驳回，返回对应状态，仅删除签名的数据，其他的数据不做处理
        if (operation == 1) {
            String rejectNodeCode = redirectQuery.getRejectNodeCode();
            rejectNodeCode = rejectNodeCode.replace("call-", "");
            if (rejectNodeCode.equals(TicketNodeStatus.WRITE.getNodeName())) {
                Integer rejectStatus = TicketStatus.WRITE.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                workPermitService.deleteByWorkTicketId(factory, workTicketId);//删除许可信息
                workTicket.setStatus(rejectStatus);
            } else if (rejectNodeCode.equals(TicketNodeStatus.SIGN.getNodeName())) {
                Integer rejectStatus = TicketStatus.SIGN.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                workPermitService.deleteByWorkTicketId(factory, workTicketId);//删除许可信息
                workTicket.setStatus(rejectStatus);
            } else if (rejectNodeCode.equals(TicketNodeStatus.COUNTERSIGN.getNodeName())) {
                Integer rejectStatus = TicketStatus.COUNTERSIGN.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                workPermitService.deleteByWorkTicketId(factory, workTicketId);//删除许可信息
                workTicket.setStatus(rejectStatus);
            } else if (rejectNodeCode.equals(TicketNodeStatus.ACCEPT.getNodeName())) {
                Integer rejectStatus = TicketStatus.ACCEPT.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                workPermitService.deleteByWorkTicketId(factory, workTicketId);//删除许可信息
                workTicket.setStatus(rejectStatus);
            } else if (StrUtil.contains(rejectNodeCode, TicketNodeStatus.PERMIT.getNodeName())) {
                // 高处作业有两个许可，平台返回的code 包含PERMIT都认为是许可节点
                Integer rejectStatus = TicketStatus.PERMIT.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                // 20211111: 如何是待许可状态，讲预览标志设置成未预览
                workTicket.setPreviewFlag(1);
                workTicket.setStatus(rejectStatus);
            } else if (rejectNodeCode.equals(TicketNodeStatus.WORK_END.getNodeName())) {
                Integer rejectStatus = TicketStatus.WORK_END.getStatus();
                fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
                workTicket.setStatus(rejectStatus);
            }
            workTicketService.update(factory, workTicket);
        } // 2. 如果通过，工作票进入下一个状态，并根据状态的不同进行不同的操作
        else if (operation == 32) {
            // 下一个节点编码
            String curNodeCode = redirectQuery.getCurNodeCode();
            curNodeCode = curNodeCode.replace("call-", "");
            String formVariables = redirectQuery.getFormVariables();
            if (status.equals(TicketStatus.WRITE.getStatus())) {
                workTicket.setStatus(2);
            }
            // 2.1 如果是签发状态，保存签名信息
            if (status.equals(TicketStatus.SIGN.getStatus())) {
                // 生成工作票号
                if (StrUtil.isBlank(workTicket.getCode())) {
                    String code = fifteenTablesService.getLastCodeByUnitAndTicketTypeNew(factory, workTicket.getUnit(), type);
                    if (StringUtils.isEmpty(code)) {
                        return Response.fail("工作票票号生成有问题，请联系运维人员");
                    }
                    workTicket.setCode(code);
                }
                // 保存签名人
                saveWorkFlow(formVariables, factory);
                workTicket.setStatus(4);//放弃自增控制，改为手动控制
            }
//            else if (status.equals(TicketStatus.COUNTERSIGN.getStatus())) {
//                // 保存签名信息
//                fifteenTablesService.saveWorkFLow(factory, formVariables);
//                workTicket.setStatus(4);//放弃自增控制，改为手动控制
//            }
            // 2.3 如果是待接收状态：1.保存签名信息；2.将预览标志设为未预览
            else if (status.equals(TicketStatus.ACCEPT.getStatus())) {
                // 将预览标志设为未预览
                workTicket.setPreviewFlag(1);
                // 保存签名人
                saveWorkFlow(formVariables, factory);
                workTicket.setStatus(5);//放弃自增控制，改为手动控制
            }
            // 2.4 如果是待许可状态，保存签名信息，以及待许可信息
            else if (status.equals(TicketStatus.PERMIT.getStatus())) {
                // 保存许可信息
                saveWorkFlow(formVariables, factory);
                workTicket.setStatus(7);//放弃自增控制，改为手动控制
            }
//            else if (status.equals(TicketStatus.WORK_END.getStatus())) {
//                WorkEnd workend = FastJsonUtils.getJsonToBean(formVariables, WorkEnd.class);
//                List<WorkFlow> workFlowList = workend.getWorkFlowList();
//                for (WorkFlow workFlow : workFlowList) {
//                    workFlowService.save(factory, workFlow);
//                }
//                workTicket.setStatus(7);//放弃自增控制，改为手动控制
//            }
            workTicketService.update(factory, workTicket);
        } else if (operation == 256) {
            Integer rejectStatus = TicketStatus.WRITE.getStatus();
            fifteenTablesService.clenWorkFlowByStatus(factory, workTicketId, rejectStatus);
            workPermitService.deleteByWorkTicketId(factory, workTicketId);//删除许可信息
            workTicket.setStatus(rejectStatus);
            workTicketService.update(factory, workTicket);
        } else {
            return Response.fail("操作类型为：" + operation + ",请联系运维人员");
        }

        return Response.success("提交成功");
    }

    /**
     * 保存签名人
     * @param formVariables
     * @param factory
     */
    private void saveWorkFlow(String formVariables, SessionFactory factory) {
        WorkPermit workPermit = JSONObject.parseObject(formVariables, WorkPermit.class);
        // 保存签名信息
        List<WorkFlow> workFlowList = workPermit.getWorkFlowList();
        if (CollUtil.isNotEmpty(workFlowList)) {
            for (WorkFlow workFLow : workFlowList) {
                workFlowService.save(factory, workFLow);
            }
        }
    }

    @TaskAnnotation("workflowUpdateEnd")
    public Response workflowUpdateEnd(SessionFactory factory, RedirectQuery redirectQuery) throws ParseException {
        String formVariables = redirectQuery.getFormVariables();
        WorkEnd workend = FastJsonUtils.getJsonToBean(formVariables, WorkEnd.class);
//        List<WorkFlow> workFlowList = workend.getWorkFlowList();
//        for (WorkFlow workFlow : workFlowList) {
//            workFlowService.save(factory, workFlow);
//        }
//        fifteenTablesService.saveWorkFLow(factory, formVariables);
        WorkTicket workticket = new WorkTicket();
        workticket.setId(workend.getWorkTicketId());
        workticket.setStatus(8);
        workTicketService.update(factory, workticket);
        return Response.success("工作票已归档", workend.getId());
    }

    @TaskAnnotation("workflowUpdateCancel")
    public Response workflowUpdateCancel(SessionFactory factory, RedirectQuery redirectQuery) {
        fifteenTablesService.workflowUpdateCancel(factory, redirectQuery);
        return Response.success("工作票已作废");
    }

    public void deleteById(SessionFactory factory, String id) {
        fifteenTablesService.deleteById(factory, id);
    }

    /**
     * 详情
     * @param factory
     * @param id
     * @return
     */
    public HoistingDto getById(SessionFactory factory, String id) {
        // 主表
        WorkTicket workTicket = workTicketService.queryById(factory, id);
        // 工作票基础信息
        TicketBaseMsg ticketBaseMsg = yccommonservice.queryTicketMsg(factory, id);
        // 高处票基础信息
        TicketYcInfoBean ycInfo = workycinfoservice.getYcInfo(factory, id);
        // 签名信息
        List<WorkFlow> workFlows = workFlowService.queryByTicketId(factory, id);

        List<HeatAnalysisBean> heatAnalysisBeans = factory.getMapper(HeatAnalysisBeanMapper.class).queryByWorkTicketId(id);

        HoistingDto dto = new HoistingDto();
        BeanUtil.copyProperties(workTicket, dto);
        BeanUtil.copyProperties(ticketBaseMsg, dto);
        BeanUtil.copyProperties(ycInfo, dto);
//        dto.setHeatanAlysislist(heatAnalysisBeans);
        dto.setId(workTicket.getId());
        dto.setWorkFlowList(workFlows);
        return dto;
    }

    /**
     *
     * 获取打印数据
     *
     * @param factory
     * @param ticketId
     * @return
     */
    @TaskAnnotation("getPrintData")
    public List<HoistingPrint> getPrintData(SessionFactory factory, String ticketId) {
        List<HoistingPrint> printlist = new ArrayList();

        // 作业类别字典
//        Map<String, String> dataDictByCode = DataDictTool.getDataDictByCode("twoTicketManagement", "ticket_task_type");

        // 主表信息
        WorkTicket workTicket = workTicketService.queryById(factory, ticketId);
        // 信息
        TicketYcInfoBean ycInfo = workycinfoservice.getYcInfo(factory, ticketId);
        // 所有签名信息
        List<WorkFlow> workFlowlist = workFlowService.queryByTicketId(factory, ticketId);
        // 基础信息
        TicketBaseMsg ticketBaseMsg = yccommonservice.queryTicketMsg(factory, ticketId);
        String locationStr = "";
        String workDeptStr = "";
        String memberNameListString = "";
        // 工作票状态
        Integer status = workTicket.getStatus();
        // 工作地点、作业地点
        if (CollUtil.isNotEmpty(ticketBaseMsg.getWorkLocationList())) {
            locationStr = ticketBaseMsg.getWorkLocationList().stream().map(WorkLocationBean::getLocationName).collect(Collectors.joining(","));
        }
        // 工作班组、作业单位
        if (CollUtil.isNotEmpty(ticketBaseMsg.getWorkTeamList())) {
            workDeptStr = ticketBaseMsg.getWorkTeamList().stream().map(WorkTeam::getWorkTeamName).collect(Collectors.joining(","));
        }
        // 工作班组成员、作业人
        if (CollUtil.isNotEmpty(ticketBaseMsg.getWorkMemberList())) {
            memberNameListString = ticketBaseMsg.getWorkMemberList().stream().map(WorkMember::getMemberName).collect(Collectors.joining(","));
        }

        Map<String, String> dictByClassCode = CodeTools.getDictByClassCode("twoTicketManagement", "ticket_hot_operation_level");


        HoistingPrint hoistingprint = new HoistingPrint();
        hoistingprint.setUnitName(workTicket.getUnitName());
        hoistingprint.setAppTime(DateUtil.format(ycInfo.getAppTime(), "yyyy年MM月dd日 HH时mm分"));
        hoistingprint.setCode(workTicket.getCode());
        hoistingprint.setLocationStr(locationStr);
        hoistingprint.setRiskResults(ycInfo.getRiskResults());// 风险识别结果
        hoistingprint.setSecurityName(ycInfo.getSecurityName());
        hoistingprint.setAcceptName(ycInfo.getAcceptName());
        hoistingprint.setContent(workTicket.getContent());

        // 实施时间
        hoistingprint.setEstimatedStartTime(DateUtil.format(workTicket.getEstimatedStartTime(), "yyyy年MM月dd日 HH时mm分"));
        hoistingprint.setEstimatedEndTime(DateUtil.format(workTicket.getEstimatedEndTime(), "yyyy年MM月dd日 HH时mm分"));
        hoistingprint.setCreateName(workTicket.getCreateUserName());

        hoistingprint.setHoistingHotools(ycInfo.getHoistingHotools());// 吊装工具名称
        hoistingprint.setOtherSpecialNum(ycInfo.getOtherSpecialNum());// 吊装人员及特殊工
        hoistingprint.setGuardianName(ycInfo.getGuardianName());// 监护人
        hoistingprint.setNumTwo(ycInfo.getNumTwo());// 吊装指挥及特殊工种作业证号
        hoistingprint.setQuality(ycInfo.getQuality());// 起吊物质量(T)


        // 签发信息 -- 作业单位负责人意见
        if (CollUtil.isNotEmpty(workFlowlist)) {
            if (status >= TicketStatus.SIGN.getStatus()) {

                Predicate<WorkFlow> predicateNode = f -> f.getStatus().equals(TicketStatus.SIGN.getStatus());//过滤节点
                Predicate<WorkFlow> predicateType = f -> StrUtil.isNotBlank(f.getType()) && f.getType().equals("name0");
                Predicate<WorkFlow> predicateTypeTwo = f -> StrUtil.isNotBlank(f.getType()) && f.getType().equals("name1");

                // 生产单位安全部门负责人
                Optional<WorkFlow> first = workFlowlist.stream().filter(predicateNode.and(predicateType)).findFirst();
                Date sigTime = first.map(WorkFlow::getOperationTime).orElse(null);
                hoistingprint.setProduceUnitPerson(first.map(WorkFlow::getName).orElse(""));
                hoistingprint.setProduceUnitTime(DateUtil.format(sigTime, "yyyy年MM月dd日 HH时mm分"));
                hoistingprint.setProduceUnitMsg(first.map(WorkFlow::getOpinion).orElse(""));

                // 生产单位（厂/站）负责人
                Optional<WorkFlow> two = workFlowlist.stream().filter(predicateNode.and(predicateTypeTwo)).findFirst();
                Date sigTimeTwo = two.map(WorkFlow::getOperationTime).orElse(null);
                hoistingprint.setStationPerson(two.map(WorkFlow::getName).orElse(""));
                hoistingprint.setStationTime(DateUtil.format(sigTimeTwo, "yyyy年MM月dd日 HH时mm分"));
                hoistingprint.setStationMsg(two.map(WorkFlow::getOpinion).orElse(""));
            }
        }

        // 接收
        if (CollUtil.isNotEmpty(workFlowlist)) {
            if (status >= TicketStatus.ACCEPT.getStatus()) {

                Predicate<WorkFlow> predicateNode = f -> f.getStatus().equals(TicketStatus.ACCEPT.getStatus());//过滤节点
                Predicate<WorkFlow> predicateType = f -> StrUtil.isNotBlank(f.getType()) && f.getType().equals("name0");
                Predicate<WorkFlow> predicateTypeTwo = f -> StrUtil.isNotBlank(f.getType()) && f.getType().equals("name1");

                // 作业单位安全部门负责人
                Optional<WorkFlow> first = workFlowlist.stream().filter(predicateNode.and(predicateType)).findFirst();
                Date sigTime = first.map(WorkFlow::getOperationTime).orElse(null);
                hoistingprint.setWorkUnitPerson(first.map(WorkFlow::getName).orElse(""));
                hoistingprint.setWorkUnitTime(DateUtil.format(sigTime, "yyyy年MM月dd日 HH时mm分"));
                hoistingprint.setWorkUnitMsg(first.map(WorkFlow::getOpinion).orElse(""));

                // 作业单位负责人
                Optional<WorkFlow> two = workFlowlist.stream().filter(predicateNode.and(predicateTypeTwo)).findFirst();
                Date sigTimeTwo = two.map(WorkFlow::getOperationTime).orElse(null);
                hoistingprint.setHeadupPerson(two.map(WorkFlow::getName).orElse(""));
                hoistingprint.setHeadupTime(DateUtil.format(sigTimeTwo, "yyyy年MM月dd日 HH时mm分"));
                hoistingprint.setHeadupMsg(two.map(WorkFlow::getOpinion).orElse(""));

            }
        }

        // 许可信息
        if (CollUtil.isNotEmpty(workFlowlist)) {
            if (status >= TicketStatus.PERMIT.getStatus()) {
                Predicate<WorkFlow> predicateNode = f -> f.getStatus().equals(TicketStatus.PERMIT.getStatus());//过滤节点
                Predicate<WorkFlow> predicateType = f -> StrUtil.isNotBlank(f.getType()) && f.getType().equals("name0");

                // 审批部门负责人
                Optional<WorkFlow> first = workFlowlist.stream().filter(predicateNode.and(predicateType)).findFirst();
                Date sigTime = first.map(WorkFlow::getOperationTime).orElse(null);
                hoistingprint.setAppDeptPerson(first.map(WorkFlow::getName).orElse(""));
                hoistingprint.setAppDeptTime(DateUtil.format(sigTime, "yyyy年MM月dd日 HH时mm分"));
                hoistingprint.setAppDeptMsg(first.map(WorkFlow::getOpinion).orElse(""));
            }
        }

        // 安全措施
        for (SecurityArrangement securityArrangement : ticketBaseMsg.getSecurityArrangementList()) {
            HoistingPrint securitybean = new HoistingPrint();
            BeanUtil.copyProperties(hoistingprint, securitybean);
            securitybean.setSecurityitem(securityArrangement.getItem());
            if (ObjectUtil.isNotNull(securityArrangement.getIsInvolve())) {
                Integer isInvolve = Integer.valueOf(securityArrangement.getIsInvolve());
                switch (isInvolve) {
                    case 1:
                        securitybean.setSecurityIsInvolve("是");
                        break;
                    case 0:
                        securitybean.setSecurityIsInvolve("否");
                        break;
                    default:
                        securitybean.setSecurityIsInvolve("");
                        break;
                }
                securitybean.setSecurityPerson(securityArrangement.getInvolveName());
            }
            printlist.add(securitybean);
        }
        return printlist;
    }

}
